package lk.icta.core.web.action;

import lk.icta.common.AppConstants;
import lk.icta.common.ELandRuntimeException;
import lk.icta.common.ErrorCodes;
import lk.icta.common.dao.DSDivisionDAO;
import lk.icta.common.dao.DistrictDAO;
import lk.icta.common.dao.GNDivisionDAO;
import lk.icta.common.dao.ProvinceDAO;
import lk.icta.common.entity.Branch;
import lk.icta.common.entity.DSDivision;
import lk.icta.common.entity.District;
import lk.icta.common.entity.Province;
import lk.icta.common.service.DocumentManagementService;
import lk.icta.common.util.LandApplicationStatUtil;
import lk.icta.common.web.action.DocumentUploadAction;
import lk.icta.core.dao.BoundaryTypeDAO;
import lk.icta.core.dao.GeologicalTypeDAO;
import lk.icta.core.dao.LocalAuthorityDAO;
import lk.icta.core.entity.*;
import lk.icta.core.entity.Land.AlienationState;
import lk.icta.core.service.AlienationManagementService;
import lk.icta.core.service.LandManagementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

public class LandDetailsAction extends DocumentUploadAction {

    private static final Logger logger = LoggerFactory.getLogger(LandDetailsAction.class);

    protected final LandManagementService landManagementService;
    protected final AlienationManagementService alienationManagementService;


    private final DistrictDAO districtDAO;
    private final DSDivisionDAO dsDivisionDAO;
    private final GNDivisionDAO gnDivisionDAO;
    private final GeologicalTypeDAO geologicalTypeDAO;
    private final BoundaryTypeDAO boundaryTypeDAO;
    private final ProvinceDAO provinceDAO;
    protected final LocalAuthorityDAO localAuthorityDAO;

    private Map<Integer, String> districtList;
    private Map<Integer, String> dsDivisionList;
    private Map<Integer, String> gnDivisionList;
    private Map<Integer, String> localAuthorityList;
    private Map<Integer, String> geologicalTypeList;
    private Map<Integer, String> alienationTypeList;
    private Map<Integer, String> boundaryTypeList;
    private Map<Integer, String> provinceList;
    private Map<Integer, String> alienationStatesList;
    private Map<Integer, String> landStateList;
    private Map<Integer, String> landApplicationStateList;
    private Map<Integer, String> migrationStateList;

    /*Newly added lists for eRail*/
    private Map<Integer, String> railwayTrackList;
    private Map<Integer, String> districtEngineerZoneList;
    private Map<Integer, String> IPWZoneList;
    private Map<Integer, String> railwayProtectionZoneList;
    private Map<Integer, String> railwayStationList;


    private Map<Integer, String> alienationMethodSet;
    private String[] alienationMethodSelectedList;
    private Map<Integer, String> amSelectedList;
    protected List<AlienationMethod> alienationMethods;

    protected LandRailway land;
    private long parentLandRefNumber;
    protected int alienationType, alienationMethod;
    protected boolean updateMode;
    private String districtName;
    private String dsDivisionName;
    private String gnDivisionName;
    protected long landId;
    private Double hectare;
    private AlienationState alieanationState;

    /*Edit Mode =1  non edit mode =0 */
    protected int editMode;

    private String searchText;
    private String searchText1;
    private String searchText2;
    private String searchText3;
    private String searchText4;


    private int searchType;
    private List<Land> landList;
    private List<Alienation> alienationList;
    private int dsDivisionId;
    private int districtId;
    private String approvalComment;

    private long slimsSerialNumber;
    private int subDivideMode;

    private int pageNo = 0;
    private boolean resetPageNo = true;
    private boolean showNextButton = false;

    //    private List<Land.Mode> modesAsList;

    public LandDetailsAction(DocumentManagementService documentManagementService, LandManagementService
            landManagementService, AlienationManagementService alienationManagementService, GNDivisionDAO gnDivisionDAO,
                             BoundaryTypeDAO boundaryTypeDAO, GeologicalTypeDAO geologicalTypeDAO,
                             LocalAuthorityDAO localAuthorityDAO, DistrictDAO districtDAO, DSDivisionDAO dsDivisionDAO, ProvinceDAO provinceDAO) {
        super(documentManagementService);
        this.landManagementService = landManagementService;
        this.alienationManagementService = alienationManagementService;
        this.districtDAO = districtDAO;
        this.dsDivisionDAO = dsDivisionDAO;
        this.gnDivisionDAO = gnDivisionDAO;
        this.boundaryTypeDAO = boundaryTypeDAO;
        this.geologicalTypeDAO = geologicalTypeDAO;
        this.localAuthorityDAO = localAuthorityDAO;
        this.provinceDAO = provinceDAO;
    }

    //initial land info - page load
    public String pageLoad() {
        populateBasicLists();
        return SUCCESS;
    }

    public String pageLoadSearch() {
        populateBasicLists();
        populateDistricts();
        return SUCCESS;
    }

    public String loadPrintPage() {
        return SUCCESS;
    }

    public String initDetailLandsReport() {
        try {

            this.populateDivisions();

            geologicalTypeList = geologicalTypeDAO.getAllGeologicalTypes(language, user);

            alienationTypeList = new LinkedHashMap<Integer, String>();
            alienationTypeList.putAll(alienationManagementService.getAllAlienationMethods(language, user));


            AlienationState[] as = AlienationState.values();
            alienationStatesList = new HashMap<Integer, String>();
            for (int x = 1; x <= as.length; x++) {
                switch (as[x - 1]) {
                    case UNALIENATED:
                        alienationStatesList.put(x, getText("unalienated_land.label"));
                        break;
                    case ALIENATED:
                        alienationStatesList.put(x, getText("alienated_land.label"));
                        break;
                    case ARCHIVED:
                        alienationStatesList.put(x, getText("archived_land.label"));
                        break;
                }
            }

            return SUCCESS;


        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            addActionError(getText("unable_to_load_land_details.label"));
            populateBasicLists();
            return ERROR;
        }

    }

    public String initLandStatistics() {
        try {
            this.populateDivisions();

            this.migrationStateList = new HashMap<Integer, String>();
            migrationStateList.put(1, getText("migrated.label"));
            migrationStateList.put(2, getText("non_migrated.label"));

            Land.ApprovalState[] las = Land.ApprovalState.values();
            landStateList = new HashMap<Integer, String>();
            for (int x = 1; x <= las.length; x++) {
                switch (las[x - 1]) {
                    case REJECTED:
                        landStateList.put(x, getText("rejected.label"));
                        break;
                    case APPROVED:
                        landStateList.put(x, getText("approve.label"));
                        break;
                    case PENDING:
                        landStateList.put(x, getText("pending.label"));
                        break;
                    case DATA_ENTRY:
                        landStateList.put(x, getText("data_entry.label"));
                        break;
                }
            }

            return SUCCESS;

        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            addActionError(getText("unable_to_load_land_details.label"));
            populateBasicLists();
            return ERROR;
        }
    }

    /*public String initLandApplicationStats() {
        try {
            this.initAllProvincesAndDivisions();

            LandApplication.State[] appState = LandApplication.State.values();
            landApplicationStateList = new HashMap<Integer, String>();
            int y = 1;
            for (LandApplication.State as : appState) {
                switch (as) {
                    case INITIAL_APPLICATION_DATA_ENTRY:
                        //TODO: Localize the workflow Task list as follows
                        *//*landApplicationStateList.put(y,getText("detailed_form_data_entry.label"));*//*
                        break;
                    case INITIAL_APPLICATION_APPROVED:
                        break;
                    case INITIAL_APPLICATION_CLOSED:
                        break;
                    case INITIAL_APPLICATION_REJECTED:
                        break;
                }
                landApplicationStateList.put(y, as.name().toString());
                y++;
            }

            WorkflowTask[] workflowTasks = WorkflowTask.values();
            for (WorkflowTask wft : workflowTasks) {
                switch (wft) {
                    case DETAILED_FORM_DATA_ENTRY:
                        //TODO: Localize the workflow Task list as follows
                        *//*landApplicationStateList.put(y,getText("detailed_form_data_entry.label"));*//*
                        break;
                    case DETAILED_FORM_APPROVED:
                        break;
                    case DETAILED_FORM_REJECTED:
                        break;
                    case INTERVIEW_DATA_ENTRY:
                        break;
                    case INTERVIEW_COMPLETED:
                        break;
                    case OBJECTION_DATA_ENTRY:
                        break;
                    case OBJECTION_HANDLING_COMPLETED:
                        break;
                    case OBJECTION_HANDLING_APPROVED:
                        break;
                    case DETAILED_FORM_FINALIZED:
                        break;
                    case LAND_ALLOCATED:
                        break;
                    case LAND_ALLOCATION_APPROVED:
                        break;
                    case LAND_ALLOCATION_REJECTED:
                        break;
                    case ACCEPTED_AND_COMPLETED:
                        break;
                    case REJECTED_AND_ARCHIVED:
                        break;
                    case NOT_SUBMITTED_AND_ARCHIVED:
                        break;
                    case ACCEPTED_AND_COMPLETED_APPLICATION_APPROVED:
                        break;
                    case ACCEPTED_AND_COMPLETED_APPLICATION_REJECTED:
                        break;
                    case REJECTED_AND_ARCHIVED_APPLICATION_APPROVED:
                        break;
                    case REJECT_REJECTED_AND_ARCHIVED_APPLICATION:
                        break;
                    case APPROVE_NOT_SUBMITTED_APPLICATION:
                        break;
                    case REJECT_NOT_SUBMITTED_APPLICATION:
                        break;
                    case SIGNED_PRINTED_ALIENATION_DOCUMENT:
                        break;
                    case UNSIGNED_PRINTED_ALIENATION_DOCUMENT:
                        break;
                    case SIGNED_ALIENATION_DOCUMENT_APPROVED:
                        break;
                    case CONDITION_SATISFIED:
                        break;
                    case ACCEPTED_LONG_TERM_LEASE:
                        break;
                    case ACCEPTED_GRANT:
                        break;
                    case ACCEPTED_RELEASING_TO_DEPARTMENT:
                        break;
                    case ACCEPTED_VESTING_ORDER:
                        break;
                    case ACCEPTED_SPECIAL_GRANT:
                        break;
                    case APPROVED:
                        break;
                    case REJECTED:
                        break;
                    case FULLY_APPROVED:
                        break;
                    case ALIENATION_APPROVED_BY_LC:
                        break;
                }
                landApplicationStateList.put(y, wft.name().toString());
                y++;
            }


            return SUCCESS;
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            addActionError(getText("unable_to_load_land_details.label"));
            populateBasicLists();
            return ERROR;
        }

    }*/

    public String initLandApplicationStats() {
        try {
            //this.initAllProvincesAndDivisions();
            this.populateDivisions();
            int y = 1;
            LandApplicationStatUtil[] statUtils = LandApplicationStatUtil.values();
            landApplicationStateList = new HashMap<Integer, String>();

            for (LandApplicationStatUtil util : statUtils) {
                if (AppConstants.SINHALA.equals(language)) {
                    landApplicationStateList.put(y, util.getSiName());
                } else if (AppConstants.TAMIL.equals(language)) {
                    landApplicationStateList.put(y, util.getTaName());
                } else {
                    landApplicationStateList.put(y, util.getEnName());
                }

                y++;
            }


            return SUCCESS;
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            addActionError(getText("unable_to_load_land_details.label"));
            populateBasicLists();
            return ERROR;
        }

    }

    /*private void initAllProvincesAndDivisions() {
        String userRole = user.getRole().getId();
        if (userProvinceId > 0) {

            provinceList = new HashMap<Integer, String>();
            Province province = provinceDAO.getProvinceById(userProvinceId);

            if (AppConstants.SINHALA.equals(language)) {
                provinceList.put(province.getId(), province.getSiProvinceName());
            } else if (AppConstants.ENGLISH.equals(language)) {
                provinceList.put(province.getId(), province.getEnProvinceName());
            } else if (AppConstants.TAMIL.equals(language)) {
                provinceList.put(province.getId(), province.getTaProvinceName());
            }

        } else {
            provinceList = provinceDAO.getProvinceList(language);
        }

        districtList = new HashMap<Integer, String>();
        if (userDistrictId > 0) {
            if (userRole.equals(AppConstants.PLC_USER_ROLE) || userRole.equals(AppConstants.APLC_USER_ROLE) || userRole.equals(AppConstants.DPLC_USER_ROLE) || userRole.equals(AppConstants.PMA_USER_ROLE)) {
                districtList = districtDAO.getAllDistrictNamesByProvinceId(userProvinceId, language, user);
            } else if (userRole.equals(AppConstants.LO_USER_ROLE) || userRole.equals(AppConstants.ORDS_USER_ROLE)) {
                District district = districtDAO.getDistrictById(userDistrictId);

                if (AppConstants.SINHALA.equals(language)) {
                    districtList.put(district.getId(), district.getSiDistrictName());
                } else if (AppConstants.ENGLISH.equals(language)) {
                    districtList.put(district.getId(), district.getEnDistrictName());
                } else if (AppConstants.TAMIL.equals(language)) {
                    districtList.put(district.getId(), district.getTaDistrictName());
                }
            }
        }

        dsDivisionList = new HashMap<Integer, String>();

        if (userRole.equals(AppConstants.LO_USER_ROLE) || userRole.equals(AppConstants.ORDS_USER_ROLE)) {
            DSDivision dsDivision = dsDivisionDAO.getDSDivisionByPK(userDsId);

            if (AppConstants.SINHALA.equals(language)) {
                dsDivisionList.put(dsDivision.getId(), dsDivision.getSiDivisionName());
            } else if (AppConstants.ENGLISH.equals(language)) {
                dsDivisionList.put(dsDivision.getId(), dsDivision.getEnDivisionName());
            } else if (AppConstants.TAMIL.equals(language)) {
                dsDivisionList.put(dsDivision.getId(), dsDivision.getTaDivisionName());
            }

        }

        if (userRole.equals(AppConstants.LO_USER_ROLE) || userRole.equals(AppConstants.ORDS_USER_ROLE)) {
            gnDivisionList = gnDivisionDAO.getGNDivisionNamesByDsDivisionId(userDsId, language, user);
        } else {
            gnDivisionList = new HashMap<Integer, String>();
        }
    }*/
/*
    public List<Land.Mode> getModesAsList() {
       return Arrays.asList(Land.Mode.values());
    }

    public void setModesAsList(List<Land.Mode> modesAsList) {
        this.modesAsList = modesAsList;
    }
*/


    /*public List<Land.Mode> getModesAsList() {
        return Arrays.asList(Land.Mode.values());
    }*/


    //initial land info - page load
    public String detailedLandListPageLoad() {
        logger.debug("detailedLandListPageLoad");
        populateDivisions();
        /*if (!user.getRole().getId().equals(AppConstants.ORIP_USER_ROLE)) {
            gnDivisionList.put(AppConstants.ALL, getText("all.label"));
        }*/
        return SUCCESS;
    }

    //add and update initial unalienated land
    protected String addInitialUnalienatedLandInformation() {
        logger.debug("Add initial unalienated land information by {}", user.getUsername());

        if (!setParentLand()) {
            populateBasicLists();
            return INPUT;
        }
        try {
            //logger.debug("Add initial unalienated land - geologycal type {}", land.getGeologicalType().getId());
            //  logger.debug("Add initial unalienated land - local authority {}", land.getLocalAuthority().getId());
            setLandLogComment("Added unalienated initial land ");
            land.setDocumentList(getUploadedfileList(ModuleType.INITIAL_LAND));
            //landManagementService.addInitialUnAlienatedLand(land, user, language);
            addActionMessage(getText("land_details_saved_successfully.label"));

            //todo : remove this
            populateBasicLists();
            return SUCCESS;

        } catch (ELandRuntimeException e) {
            switch (e.getErrorCode()) {
                case ErrorCodes.UNAUTHORIZED_ACCESS:
                    addActionError(getText("permission_denied.label"));
                    break;
            }
            populateBasicLists();
            return INPUT;
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            addActionError(getText("unable_to_save_land_details.label"));
            populateBasicLists();
            return INPUT;
        }
    }

    //todo: to be refactored
    public String deleteDetailLandInformation() {
        logger.debug("Delete detailed land information of land {} by {}", landId, user.getUsername());
        try {
            Land deleteLand = landManagementService.getLandById(landId);
            if (Land.AlienationState.UNALIENATED.equals(deleteLand.getAlienationState())) {
                landManagementService.deleteDetailUnAlienatedLandFromDatabase(deleteLand, user);
            } else {
                Alienation deleteAlienation = alienationManagementService.getActiveAlienationByLandId(deleteLand.getId(), user);
                landManagementService.deleteDetailAlienatedLandFromDatabase(deleteLand, deleteAlienation.getId(), user);
            }
            populateBasicLists();
            addActionMessage(getText("land_deleted.label"));
            return SUCCESS;
        } catch (ELandRuntimeException e) {
            switch (e.getErrorCode()) {
                case ErrorCodes.UNAUTHORIZED_ACCESS:
                    addActionError(getText("permission_denied.label"));
                    break;
            }
            return ERROR;
        }
    }


    /*protected void populateDistricts() {
        if (!user.getDsDivisions().isEmpty() && !user.getRole().getId().equals(AppConstants.ORIP_USER_ROLE)) {
            DSDivision userDS = user.getDsDivisions().iterator().next();  //find the DS division of DS user
            gnDivisionList = gnDivisionDAO.getGNDivisionNamesByDsDivisionId(userDS.getId(), language, user);
            gnDivisionList.remove(AppConstants.ALL);
            if (AppConstants.ENGLISH.equals(language)) {
                dsDivisionName = userDS.getCode() + " : " + userDS.getEnDivisionName();
                districtName = userDS.getDistrict().getCode() + " : " + userDS.getDistrict().getEnDistrictName();

            } else if (AppConstants.SINHALA.equals(language)) {
                dsDivisionName = userDS.getCode() + " : " + userDS.getSiDivisionName();
                districtName = userDS.getDistrict().getCode() + " : " + userDS.getDistrict().getSiDistrictName();

            } else if (AppConstants.TAMIL.equals(language)) {
                dsDivisionName = userDS.getCode() + " : " + userDS.getTaDivisionName();
                districtName = userDS.getDistrict().getCode() + " : " + userDS.getDistrict().getTaDistrictName();

            }
            //get localAuthority
            //TODO: this is wrong. refactore this methos and use preloaded list by language
            displayLocalAuthority(userDS.getId());
        } else {
            //use for ORIP users
            populateDistricts();
            localAuthorityList = new HashMap<Integer, String>();


        }
    }*/

    protected void populateDivisions() {
            if (!user.getDistricts().isEmpty()) {
                District userDistrict = user.getDistricts().iterator().next();

                if (AppConstants.ENGLISH.equals(language)) {
                    districtName = userDistrict.getCode() + " : " + userDistrict.getEnDistrictName();


                } else if (AppConstants.SINHALA.equals(language)) {
                    districtName = userDistrict.getCode() + " : " + userDistrict.getSiDistrictName();

                } else if (AppConstants.TAMIL.equals(language)) {
                    districtName = userDistrict.getCode() + " : " + userDistrict.getTaDistrictName();

                }

            }
    }


    protected void loadDsAndGnListByLand(Land land) {
        if (user.getRole().getId().equals(AppConstants.ORIP_USER_ROLE) && land != null && land.getGnDivision() != null) {
            dsDivisionList = dsDivisionDAO.getDSDivisionNamesByDistrictId(land.getGnDivision().getDistrictId(), language, user);
            gnDivisionList = gnDivisionDAO.getGNDivisionNamesByDsDivisionId(land.getGnDivision().getDsDivision().getId(), language, user);
            List<LocalAuthority> laList = localAuthorityDAO.getLocalAuthorityForDSDivisionByDSDivisionId(land.getGnDivision().getDsDivision().getId(), user);
            populateLocalAuthorityList(laList);
            logger.debug("localAuthorityList {} ", localAuthorityList.size());
        }
    }

    private void populateLocalAuthorityList(List<LocalAuthority> laList) {
        for (LocalAuthority la : laList) {
            //language processing
            if (AppConstants.SINHALA.equals(language)) {
                localAuthorityList.put(la.getId(), la.getSiName() + " " + la.getLocalAuthorityType().getSiName());
            } else if (AppConstants.ENGLISH.equals(language)) {
                localAuthorityList.put(la.getId(), la.getEnName() + " " + la.getLocalAuthorityType().getEnName());
            } else if (AppConstants.TAMIL.equals(language)) {
                localAuthorityList.put(la.getId(), la.getTaName() + " " + la.getLocalAuthorityType().getTaName());
            }
        }
    }

    //Populate Basic Lists of Land Details
    protected void populateBasicLists() {
        try {
            logger.debug("Populate Basic Lists of Land Details by {}", user.getUsername());
            populateDivisions();
            geologicalTypeList = geologicalTypeDAO.getAllGeologicalTypes(language, user);
            boundaryTypeList = boundaryTypeDAO.getAllBoundaryTypesByUserLanguage(language, user);
            alienationTypeList = new LinkedHashMap<Integer, String>();
            //alienationTypeList.put(-1, "Un-Alienated");
            setUnAlienatedString(alienationTypeList);

            alienationTypeList.putAll(alienationManagementService.getAllAlienationMethods(language, user));
            findDocumentCategoryList(ModuleType.INITIAL_LAND);

            districtEngineerZoneList = new HashMap<Integer, String>();
            IPWZoneList = new HashMap<Integer, String>();
            railwayProtectionZoneList = new HashMap<Integer, String>();
            railwayStationList = new HashMap<Integer, String>();
            railwayTrackList  = new HashMap<Integer, String>();


            //kk
            alienationMethodSet = new HashMap<Integer, String>();
            for (int i = 1; i < alienationTypeList.size(); i++) {
                alienationMethodSet.put(i, alienationTypeList.get(i));
            }

        } catch (Exception e) {
            logger.debug("Error: ", e.getMessage());
            e.printStackTrace();
        }
    }

    protected List<AlienationMethod> populateAlienationMethods() {
        logger.debug("populating AM List");
        List<AlienationMethod> amList = new ArrayList<AlienationMethod>();
        if (alienationMethodSelectedList != null) {
            for (String am : alienationMethodSelectedList) {
                //TODO : get from service
                logger.debug("AM ID {} ", am);
                amList.add(alienationManagementService.getAlienationMethodById(Integer.parseInt(am), user));
            }
        }
        return amList;
    }

    protected void populateAlienationMethodIds() {
        logger.debug("populating AM List");

        amSelectedList = new HashMap<Integer, String>();

        if (getAlienationMethods() != null && getAlienationMethods().size() != 0) {

            for (AlienationMethod am : getAlienationMethods()) {

                logger.debug("AM array  - id {} ", am.getId());

                //TODO Find by language
                amSelectedList.put(am.getId(), am.getEnName());
            }
        }
    }

    //Populate Print Data of Land Details
    protected void populatePrintData() {
        try {
            logger.debug("Populate Print Data of Land Details by {}", user.getUsername());

            if (land != null) {
                //DSDivision landDS = land.getGnDivision().getDsDivision();
                if (AppConstants.ENGLISH.equals(language)) {
                    //dsDivisionName = landDS.getCode() + " : " + landDS.getEnDivisionName();
                   // districtName = landDS.getDistrict().getCode() + " : " + landDS.getDistrict().getEnDistrictName();
                    //gnDivisionName = land.getGnDivision().getCode() + " : " + land.getGnDivision().getEnDivisionName();

                } else if (AppConstants.SINHALA.equals(language)) {
                    //dsDivisionName = landDS.getCode() + " : " + landDS.getSiDivisionName();
                    //districtName = landDS.getDistrict().getCode() + " : " + landDS.getDistrict().getSiDistrictName();
                    //gnDivisionName = land.getGnDivision().getCode() + " : " + land.getGnDivision().getSiDivisionName();

                } else if (AppConstants.TAMIL.equals(language)) {
                    //dsDivisionName = landDS.getCode() + " : " + landDS.getTaDivisionName();
                    //districtName = landDS.getDistrict().getCode() + " : " + landDS.getDistrict().getTaDistrictName();
                    //gnDivisionName = land.getGnDivision().getCode() + " : " + land.getGnDivision().getSiDivisionName();

                }
                logger.debug("Populate Print Data of Land Details dsDivisionName {}", dsDivisionName);

                //get localAuthority
                //displayLocalAuthority(landDS.getId());
            }

        } catch (Exception e) {
            logger.debug("Error: ", e.getMessage());
            e.printStackTrace();
        }
    }

    private void setUnAlienatedString(Map<Integer, String> alienationTypeList) {
        if (AppConstants.ENGLISH.equals(language)) {
            alienationTypeList.put(-1, AppConstants.UN_ALIENATED_EN);

        } else if (AppConstants.SINHALA.equals(language)) {
            alienationTypeList.put(-1, AppConstants.UN_ALIENATED_SI);

        } else if (AppConstants.TAMIL.equals(language)) {
            alienationTypeList.put(-1, AppConstants.UN_ALIENATED_TA);

        }

    }

    public void displayLocalAuthority(int dsDivisionId) {
        //get localAuthority
        List<LocalAuthority> results = localAuthorityDAO.getLocalAuthorityForDSDivisionByDSDivisionId(dsDivisionId, user);
        logger.debug("Auth list {}", results.size());
        localAuthorityList = new HashMap<Integer, String>();
        for (LocalAuthority la : results) {
            if (AppConstants.ENGLISH.equals(language)) {
                localAuthorityList.put(la.getId(), la.getEnName() + " " + la.getLocalAuthorityType().getEnName());

            } else if (AppConstants.SINHALA.equals(language)) {
                localAuthorityList.put(la.getId(), la.getSiName() + " " + la.getLocalAuthorityType().getSiName());

            } else if (AppConstants.TAMIL.equals(language)) {
                localAuthorityList.put(la.getId(), la.getTaName() + " " + la.getLocalAuthorityType().getTaName());

            }
        }
    }

    protected boolean setParentLand() {
        logger.debug("Setting Parent Land");
        try {
            if (parentLandRefNumber != 0) {


                //serch approved, active land by ref
                Land parentLand = landManagementService.getLandById(parentLandRefNumber);
                if (parentLand == null) {
                    addActionError("Invalid Land Reference Number. Please check GEO Reference Number.");
                    return false;
                } else {
                    if (parentLand.getApprovalState() == Land.ApprovalState.APPROVED) {
                       // land.setParentLand(parentLand);
                    } else {
                        addActionError("Invalid Parent Land. The Parent Land has not been approved yet.");
                        return false;
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

    protected boolean validateParentLand() {
        logger.debug("Setting Parent Land");
        try {
            if (parentLandRefNumber != 0) {

                //serch approved, active land by ref
                Land parentLand = landManagementService.getLandById(parentLandRefNumber);
                if (parentLand == null) {
                    addActionError("Invalid Land Reference Number. Please check GEO Reference Number.");
                    return false;
                } else {
                    if (parentLand.getApprovalState() == Land.ApprovalState.APPROVED) {
                        //land.setParentLand(parentLand);
                    } else {
                        addActionError("Invalid Parent Land. The Parent Land has not been approved yet.");
                        return false;
                    }
                }
            } else {
                addActionError("SLIMS Serial Number can not be empty!");
                return false;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

    //todo: refactore and remove
    protected void populateLandInformation() {
        logger.debug("Populate Basic Lists according to alienation GN Division[user name: {}]", user.getUsername());
        try {
            hectare = land.getLandExtent() * 0.002529285264;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    ///////////////////
    //Land Search
    public String searchLands() {
        logger.debug("Load all active approved lands by {}", user.getUsername());
        try {
            logger.debug("Search Land DsDivitionId {} by {}", dsDivisionId, user.getUsername());
            landList = new ArrayList<Land>();
            /*if (dsDivisionId != 0) {
                //search by UpperLevel plc,lcg
                if(districtId==0){
                     landList = landManagementService.searchAllActiveApprovedLandsOfDistrict(districtId);
                }else{
                     landList = landManagementService.searchAllActiveApprovedLandsOfDSDivision(dsDivisionId);
                }
                populateDistricts();

            } else {
                //search by Low level
                for (DSDivision dsDivision : user.getDsDivisions()) {
                    if (dsDivision != null) {
                        landList.addAll(landManagementService.searchAllActiveApprovedLandsOfDSDivision(dsDivision.getId()));

                    }
                }

            }    */


            if (dsDivisionId == 0) {
                if (districtId == 0) {
                    //search by Low level
                    for (DSDivision dsDivision : user.getDsDivisions()) {
                        if (dsDivision != null) {
                            landList.addAll(landManagementService.searchAllActiveApprovedLandsOfDSDivision(dsDivision.getId()));

                        }
                    }
                } else {
                    logger.debug("search By DistrictId {} ", districtId);
                    landList = landManagementService.searchAllActiveApprovedLandsOfDistrict(districtId);
                }

            } else {
                landList = landManagementService.searchAllActiveApprovedLandsOfDSDivision(dsDivisionId);
            }
            populateDistricts();
            dsDivisionList = dsDivisionDAO.getDSDivisionNamesByDistrictId(districtId, language, user);

        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        searchText = "";
        return SUCCESS;
    }


    public String searchAllLands() {
        logger.debug("Load all active approved lands by {}", user.getUsername());
        try {
            logger.debug("Search Land DsDivitionId {} by {}", dsDivisionId, user.getUsername());
            landList = new ArrayList<Land>();

           /*  if (dsDivisionId == 0) {
                if (districtId == 0) {
                    //search by Low level
                    for (DSDivision dsDivision : user.getDsDivisions()) {
                        if (dsDivision != null) {
                            landList.addAll(landManagementService.searchAllLandsOfDSDivision(dsDivision.getId()));

                        }
                    }
                } else {
                    logger.debug("search By DistrictId {} ", districtId);
                    landList = landManagementService.searchAllLandsOfDistrict(districtId);
                }

            } else {
                landList = landManagementService.searchAllLandsOfDSDivision(dsDivisionId);
            }*/
            populateDistricts();
            dsDivisionList = dsDivisionDAO.getDSDivisionNamesByDistrictId(districtId, language, user);

        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        searchText = "";


        return SUCCESS;
    }

    /*
     * All lands search, next page for upper levels than ORDS level using searchLAllLandsUpperLevel.jsp
     */
    public String searchAllLandByDSUpperLevelNextPageId() {
        pageNo++;
        resetPageNo = false;
        searchAllLandByDSUpperLevel();
        return SUCCESS;
    }

    /*
     * All lands search, back page for upper levels than ORDS level using searchLAllLandsUpperLevel.jsp
     */
    public String searchAllLandByDSUpperLevelBackPageId() {
        if (pageNo > 1) {
            pageNo--;
        }
        resetPageNo = false;
        searchAllLandByDSUpperLevel();
        return SUCCESS;
    }

    /*
    * All lands search for upper levels than ORDS level using searchLAllLandsUpperLevel.jsp
    * search param: landName, planNo,lotNo,holderName,districtId,dsDivisionId
    */
    public String searchAllLandByDSUpperLevel() {
        logger.debug("Load all lands upper user {} pageNo {}", user.getUsername(), pageNo);
        if (resetPageNo || pageNo == 0) {
            pageNo = 1;
        }
        try {
            logger.debug("Search Land DsDivitionId {} by {}", dsDivisionId, user.getUsername());
            landList = new ArrayList<Land>();
            if (dsDivisionId == 0) { // Not selected the ds division
                if (districtId == 0) {
                    // Not selected the ds division, search from all lands in user area
                    landList.addAll(landManagementService.searchAllLandsOfManyDSDivisionsOfUpperLevel(searchText1, searchText2,
                            searchText3, searchText4, user, pageNo));
                } else {
                    // Only selected the district, search from all lands in selected district
                    logger.debug("search By DistrictId {} ", districtId);
                    landList = landManagementService.searchAllLandsOfDistrict(searchText1, searchText2,
                            searchText3, searchText4, districtId, pageNo);
                }

            } else {
                // Search from  lands in selected district and Ds division
                landList = landManagementService.searchAllLandsOfDSDivision(searchText1, searchText2,
                        searchText3, searchText4, dsDivisionId, pageNo);
            }
            if (landList.size() < AppConstants.MAX_ROWS_PER_PAGE) {
                showNextButton = false;
            } else {
                showNextButton = true;
            }
            populateDistricts();
            dsDivisionList = dsDivisionDAO.getDSDivisionNamesByDistrictId(districtId, language, user);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        searchText = "";
        return SUCCESS;
    }


    public String searchLandUsingSearchText() {
        logger.debug("Search Land by :{} ", user.getUsername());
        logger.debug("Search Land Search Txt: {} SearchType :{} ", searchText, searchType);

        try {

            landList = new ArrayList<Land>();
            if (searchType == 1) { //search by LandName
                landList = landManagementService.searchActiveLandsOfDSDivisionByLandName(searchText, user);

            } else if (searchType == 2) {//search by PlanNo
                landList = landManagementService.searchActiveLandsOfDSDivisionByPlanNo(searchText, user);

            } else if (searchType == 3) { //search by LotNo
                landList = landManagementService.searchActiveLandsOfDSDivisionByLotNo(searchText, user);

            } else if (searchType == 4) { //search by HolderName
                landList = landManagementService.searchActiveLandsOfDSDivisionByHolderName(searchText, user);

            }

            if (dsDivisionId == 0) {
                populateDistricts();
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        searchText = "";
        return SUCCESS;
    }

    /*
    * All lands search, Next page for ORDS and lower level using searchLAllLands.jsp
    */
    public String searchAllLandUsingSearchTextNextPageId() {
        pageNo = pageNo + 1;
        logger.debug("Search All Land Next Page user :{} pageNo : {}", user.getUsername(), pageNo);
        resetPageNo = false;
        searchAllLandUsingSearchText();
        return SUCCESS;
    }

    /*
    * All lands search, Next page for ORDS and lower level using searchLAllLands.jsp
    */
    public String searchAllLandUsingSearchTextBackPageId() {
        if (pageNo > 1) {
            pageNo = pageNo - 1;
        }
        logger.debug("Search All Land Back Page user :{} pageNo : {}", user.getUsername(), pageNo);
        resetPageNo = false;
        searchAllLandUsingSearchText();
        return SUCCESS;
    }

    /*
     * All lands search for ORDS and lower level using searchLAllLands.jsp
     */
    public String searchAllLandUsingSearchText() {
        logger.debug("Search All Land by :{} ", user.getUsername());
        if (resetPageNo || pageNo == 0) {
            pageNo = 1;
        }

        try {
            landList = new ArrayList<Land>();
            landList = landManagementService.searchAllLandsOfDSDivisionBySearchText(searchText1, searchText2, searchText3, searchText4, user, pageNo);
            logger.debug("landList size {} and {}", landList.size(), AppConstants.MAX_ROWS_PER_PAGE);
            //Next button will be shown when showNextButton=true. Fails only when last page entries = MAX_ROWS_PER_PAGE
            if (landList.size() < AppConstants.MAX_ROWS_PER_PAGE) {
                showNextButton = false;
            } else {
                showNextButton = true;
            }
            resetPageNo = true;
            if (dsDivisionId == 0) {
                populateDistricts();
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return SUCCESS;
    }


    public String alienationByAlienationType() {
        logger.debug("Search lands by alienation type {} by {}", alienationType, user.getUsername());
        try {
            if (alienationType == 0) {
                alienationList = alienationManagementService.getAllActiveAlienation(user);
            } else {
                alienationList = alienationManagementService.getAlienationByAlienationMethod(alienationType, user);
            }
            populateBasicLists();
            alienationTypeList.remove(-1);
            return SUCCESS;
        } catch (ELandRuntimeException e) {
            e.printStackTrace();
            logger.error(e.getMessage());
            return ERROR;
        }
    }

    public String getPermitAlienations() {
        logger.debug("Search lands by alienation Permit by {}", user.getUsername());
        try {
            alienationType = AppConstants.LAND_PERMIT;
            if (alienationType == AppConstants.LAND_PERMIT) {
                alienationList = alienationManagementService.getAllAlienationByAlienationMethod(alienationType, user);
                logger.debug("alienationList size {}", alienationList.size());
                for (Alienation a : alienationList) {
                    landList.add(a.getLand());
                }
            }
            populateBasicLists();
            return SUCCESS;
        } catch (ELandRuntimeException e) {
            e.printStackTrace();
            logger.error(e.getMessage());
            return ERROR;
        }
    }

    /////////////////////////////
    private void populateDistricts() {
        try {
            logger.debug("Populate District Lists by {}  province {}", user.getUsername(), userProvinceId);
            /*districtList = districtDAO.getAllDistrictNamesByProvinceId(1, user.getPrefLanguage(), user);
            dsDivisionList = dsDivisionDAO.getDSDivisionNamesByDistrictId(1, language, user);
            gnDivisionList = gnDivisionDAO.getGNDivisionNamesByDsDivisionId(1, user.getPrefLanguage(), user);*/

            //districtList = districtDAO.getAllDistrictNamesByProvinceId(userProvinceId, user.getPrefLanguage(), user);
            if (userProvinceId > 0) {
                districtList = districtDAO.getAllDistrictNamesByProvinceId(userProvinceId, language, user);
            } else {
                districtList = districtDAO.getAllDistrictNames(language, user);
            }
            /*dsDivisionList = dsDivisionDAO.getDSDivisionNamesByDistrictId(userDistrictId, language, user);
            gnDivisionList = gnDivisionDAO.getGNDivisionNamesByDsDivisionId(userDsId, user.getPrefLanguage(), user);*/

            dsDivisionList = new HashMap<Integer, String>();
            gnDivisionList = new HashMap<Integer, String>();


        } catch (Exception ex) {
            ex.printStackTrace();
            logger.debug("TryCatchError", ex.getMessage());
        }
    }

    public String approveLandInformation() {
        logger.debug("Approve  Land information of land id {} by {}", land.getId(), user.getUsername());
        try {
            //landManagementService.approveLandInformation(land, approvalComment, user);
            addActionMessage(getText("land_approved_successfully.label"));

            populateBasicLists();
            return SUCCESS;
        } catch (ELandRuntimeException e) {
            switch (e.getErrorCode()) {
                case ErrorCodes.UNAUTHORIZED_ACCESS:
                    addActionError(getText("permission_denied.label"));
                    break;
                case ErrorCodes.ARCHIVED_LAND_APPROVAL:
                    addActionError(getText("history_record_cannot_be_approved.label"));
                    break;
                case ErrorCodes.APPROVED_LAND_APPROVAL:
                    addActionError(getText("already_approved_land.label"));
                    break;
                case ErrorCodes.REJECTED_LAND_APPROVAL:
                    addActionError(getText("already_rejected_land.label"));
                    break;
                case ErrorCodes.ARCHIVED_ALIENATION_APPROVAL:
                    addActionError(getText("history_record_cannot_be_approved.label"));
                    break;
                case ErrorCodes.APPROVED_ALIENATION_APPROVAL:
                    addActionError(getText("already_approved_alienation.label"));
                    break;
                case ErrorCodes.REJECTED_ALIENATION_APPROVAL:
                    addActionError(getText("already_rejected_alienation.label"));
                    break;
                case ErrorCodes.ILLEGAL_STATE:
                    addActionError(getText("error_occured.label"));
                    break;
                case ErrorCodes.INCOMPLETE_LAND_APPROVAL:
                case ErrorCodes.INCOMPLETE_ALIENATION_APPROVAL:
                    addActionError(getText("incomplete_record.label"));
                    break;
                default:
                    addActionError(getText("unable_to_approve.label"));
            }
            e.printStackTrace();
            logger.error(e.getMessage());
            return ERROR;
        }
    }

    public String rejectLandInformation() {
        logger.debug("Reject  Land information of land id {} by {}", land.getId(), getUser().getUsername());
        try {
           // landManagementService.rejectLandInformation(land, approvalComment, user);
            addActionMessage(getText("land_rejected_successfully.label"));
            populateBasicLists();
            return SUCCESS;
        } catch (ELandRuntimeException e) {
            switch (e.getErrorCode()) {
                case ErrorCodes.UNAUTHORIZED_ACCESS:
                    addActionError(getText("permission_denied.label"));
                    break;
                case ErrorCodes.ARCHIVED_LAND_REJECTION:
                    addActionError(getText("history_record_cannot_be_approved.label"));
                    break;
                case ErrorCodes.APPROVED_LAND_REJECTION:
                    addActionError(getText("already_approved_land.label"));
                    break;
                case ErrorCodes.REJECTED_LAND_REJECTION:
                    addActionError(getText("already_rejected_land.label"));
                    break;
                case ErrorCodes.ARCHIVED_ALIENATION_REJECTION:
                    addActionError(getText("history_record_cannot_be_approved.label"));
                    break;
                case ErrorCodes.APPROVED_ALIENATION_REJECTION:
                    addActionError(getText("already_approved_alienation.label"));
                    break;
                case ErrorCodes.REJECTED_ALIENATION_REJECTION:
                    addActionError(getText("already_rejected_alienation.label"));
                    break;
                case ErrorCodes.ILLEGAL_STATE:
                    addActionError(getText("error_occured.label"));
                    break;
                case ErrorCodes.INCOMPLETE_LAND_REJECTION:
                case ErrorCodes.INCOMPLETE_ALIENATION_REJECTION:
                    addActionError(getText("incomplete_record.label"));
                    break;
                default:
                    addActionError(getText("unable_to_approve.label"));
            }
            e.printStackTrace();
            logger.error(e.getMessage());
            return ERROR;
        }
    }

    public String findClildrenByParentLand() {
        logger.debug("find Clildren By Parent Land {} ", user.getUsername());
       // land = landManagementService.getLandById(landId);
        landList = new ArrayList<Land>();
        //landList.add(land);

        populateLandChildren(landId);

        logger.debug("Land List Size {}", landList.size());
        if (landList.size() == 1) {
            return "landDetails";
        } else {
            return "landList";
        }
    }

    private void populateLandChildren(long parentLandId) {
        logger.debug("populate Land Children {}", user.getUsername());
        //  List<Land> landChildList = new ArrayList<Land>();

        //  while (landChildList != null) {
        List<Land> landChildList = landManagementService.searchChildrenByParentLand(user, parentLandId);
        if (landChildList != null) {
            logger.debug("Land Children list size {}", landChildList.size());
            landList.addAll(landChildList);

            for (Land land : landChildList) {
                parentLandId = land.getId();
                populateLandChildren(parentLandId);
            }
        }
    }


    public String populateInitLandSubDivideApplication() {
        try {
            logger.debug("populate init Land Sub Divide Application slims No: {}", slimsSerialNumber);
            logger.debug("populate init Land Sub Divide Application land No: {}", landId);
            logger.debug("populate init Land Sub Divide Application subDivideMode: {}", subDivideMode);
            //Land exsistLand = landManagementService.getLandById(slimsSerialNumber);
            Land exsistLand = landManagementService.getApprovedUnAlienatedLandById(slimsSerialNumber);
            if (exsistLand != null) {

                if (subDivideMode == 1) {
                    //edit
                    //land = landManagementService.getLandById(landId);
                    parentLandRefNumber = slimsSerialNumber;
                   // land.setParentLand(exsistLand);

                } else {
                    //new
                    //land = new Land();
                    //land.setGnDivision(exsistLand.getGnDivision());
                    //land.setLocalAuthority(exsistLand.getLocalAuthority());
                    parentLandRefNumber = slimsSerialNumber;

                }

                populateBasicLists();
            } else {
                //initGrantPage = true;
                addActionError(getText("requested_entry_not_available.label"));
            }

        } catch (Exception e) {
            //initGrantPage = true;
            addActionError(getText("requested_entry_not_available.label"));
            e.printStackTrace();
            logger.debug("Error e :{}", e);
        }

        return SUCCESS;
    }

    public String populateEditLandSubDivideApplication() {
        try {
            logger.debug("populate Edit Land Sub Divide Application slims No: {}", landId);
            Land exsistLand = landManagementService.getLandById(landId);
            //Land exsistLand = landManagementService.getApprovedUnAlienatedLandById(slimsSerialNumber);
            if (exsistLand != null) {
                /*land = new Land();
                land.setGnDivision(exsistLand.getGnDivision());
                land.setLocalAuthority(exsistLand.getLocalAuthority());*/
                //land = exsistLand;
                //parentLandRefNumber = land.getParentLand().getId();

                populateBasicLists();
            } else {
                //initGrantPage = true;
                addActionError(getText("requested_entry_not_available.label"));
            }

        } catch (Exception e) {
            //initGrantPage = true;
            addActionError(getText("requested_entry_not_available.label"));
            e.printStackTrace();
            logger.debug("Error e :{}", e);
        }

        return SUCCESS;
    }

    protected void setLandLogComment(String approveStr) {
        if (land.getApprovalNote() != null) {
            land.setApprovalNote(land.getApprovalNote() + "\n" + approveStr + " by :" + user.getUsername() + ", Date : " + new Date() + ".");
        } else {
            land.setApprovalNote(approveStr + " by :" + user.getUsername() + ", Date : " + new Date() + ".");
        }
    }

    public Map<Integer, String> getGnDivisionList() {
        return gnDivisionList;
    }

    public void setGnDivisionList(Map<Integer, String> gnDivisionList) {
        this.gnDivisionList = gnDivisionList;
    }


    public Map<Integer, String> getLocalAuthorityList() {
        return localAuthorityList;
    }

    public void setLocalAuthorityList(Map<Integer, String> localAuthorityList) {
        this.localAuthorityList = localAuthorityList;
    }

    public Map<Integer, String> getGeologicalTypeList() {
        return geologicalTypeList;
    }

    public void setGeologicalTypeList(Map<Integer, String> geologicalTypeList) {
        this.geologicalTypeList = geologicalTypeList;
    }

    public Map<Integer, String> getAlienationTypeList() {
        return alienationTypeList;
    }

    public void setAlienationTypeList(Map<Integer, String> alienationTypeList) {
        this.alienationTypeList = alienationTypeList;
    }

    public Map<Integer, String> getBoundaryTypeList() {
        return boundaryTypeList;
    }

    public void setBoundaryTypeList(Map<Integer, String> boundaryTypeList) {
        this.boundaryTypeList = boundaryTypeList;
    }

    public LandRailway getLand() {
        return land;
    }

    public void setLand(LandRailway land) {
        this.land = land;
    }

    public long getParentLandRefNumber() {
        return parentLandRefNumber;
    }

    public void setParentLandRefNumber(long parentLandRefNumber) {
        this.parentLandRefNumber = parentLandRefNumber;
    }

    public int getAlienationType() {
        return alienationType;
    }

    public void setAlienationType(int alienationType) {
        this.alienationType = alienationType;
    }

    public boolean isUpdateMode() {
        return updateMode;
    }

    public void setUpdateMode(boolean updateMode) {
        this.updateMode = updateMode;
    }

    public String getDistrictName() {
        return districtName;
    }

    public void setDistrictName(String districtName) {
        this.districtName = districtName;
    }

    public String getDsDivisionName() {
        return dsDivisionName;
    }

    public void setDsDivisionName(String dsDivisionName) {
        this.dsDivisionName = dsDivisionName;
    }

    public long getLandId() {
        return landId;
    }

    public void setLandId(long landId) {
        this.landId = landId;
    }

    public Double getHectare() {
        return hectare;
    }

    public void setHectare(Double hectare) {
        this.hectare = hectare;
    }

    public int getAlienationMethod() {
        return alienationMethod;
    }

    public void setAlienationMethod(int alienationMethod) {
        this.alienationMethod = alienationMethod;
    }

    public int getEditMode() {
        return editMode;
    }

    public void setEditMode(int editMode) {
        this.editMode = editMode;
    }

    public String getSearchText() {
        return searchText;
    }

    public void setSearchText(String searchText) {
        this.searchText = searchText;
    }

    public int getDsDivisionId() {
        return dsDivisionId;
    }

    public void setDsDivisionId(int dsDivisionId) {
        this.dsDivisionId = dsDivisionId;
    }

    public Map<Integer, String> getProvinceList() {
        return provinceList;
    }

    public void setProvinceList(Map<Integer, String> provinceList) {
        this.provinceList = provinceList;
    }

    public Map<Integer, String> getDistrictList() {
        return districtList;
    }

    public void setDistrictList(Map<Integer, String> districtList) {
        this.districtList = districtList;
    }

    public Map<Integer, String> getDsDivisionList() {
        return dsDivisionList;
    }

    public void setDsDivisionList(Map<Integer, String> dsDivisionList) {
        this.dsDivisionList = dsDivisionList;
    }

    public List<Land> getLandList() {
        return landList;
    }

    public void setLandList(List<Land> landList) {
        this.landList = landList;
    }

    public int getSearchType() {
        return searchType;
    }

    public void setSearchType(int searchType) {
        this.searchType = searchType;
    }

    public List<Alienation> getAlienationList() {
        return alienationList;
    }

    public void setAlienationList(List<Alienation> alienationList) {
        this.alienationList = alienationList;
    }

    public int getDistrictId() {
        return districtId;
    }

    public void setDistrictId(int districtId) {
        this.districtId = districtId;
    }

    public String getApprovalComment() {
        return approvalComment;
    }

    public void setApprovalComment(String approvalComment) {
        this.approvalComment = approvalComment;
    }

    public long getSlimsSerialNumber() {
        return slimsSerialNumber;
    }

    public void setSlimsSerialNumber(long slimsSerialNumber) {
        this.slimsSerialNumber = slimsSerialNumber;
    }

    public int getSubDivideMode() {
        return subDivideMode;
    }

    public void setSubDivideMode(int subDivideMode) {
        this.subDivideMode = subDivideMode;
    }

    public String getGnDivisionName() {
        return gnDivisionName;
    }

    public void setGnDivisionName(String gnDivisionName) {
        this.gnDivisionName = gnDivisionName;
    }


    public Map<Integer, String> getAlienationMethodSet() {
        return alienationMethodSet;
    }

    public void setAlienationMethodSet(Map<Integer, String> alienationMethodSet) {
        this.alienationMethodSet = alienationMethodSet;
    }


    public String[] getAlienationMethodSelectedList() {
        return alienationMethodSelectedList;
    }

    public void setAlienationMethodSelectedList(String[] alienationMethodSelectedList) {
        this.alienationMethodSelectedList = alienationMethodSelectedList;
    }

    public Map<Integer, String> getAmSelectedList() {
        return amSelectedList;
    }

    public void setAmSelectedList(Map<Integer, String> amSelectedList) {
        this.amSelectedList = amSelectedList;
    }

    public List<AlienationMethod> getAlienationMethods() {
        return alienationMethods;
    }

    public void setAlienationMethods(List<AlienationMethod> alienationMethods) {
        this.alienationMethods = alienationMethods;
    }

    public Map<Integer, String> getAlienationStatesList() {
        return alienationStatesList;
    }

    public AlienationState getAlieanationState() {
        return alieanationState;
    }

    public void setAlieanationState(AlienationState alienationState) {
        this.alieanationState = alienationState;
    }

    public Map<Integer, String> getLandStateList() {
        return landStateList;
    }

    public void setLandStateList(Map<Integer, String> landStateList) {
        this.landStateList = landStateList;
    }

    public Map<Integer, String> getLandApplicationStateList() {
        return landApplicationStateList;
    }

    public void setLandApplicationStateList(Map<Integer, String> landApplicationStateList) {
        this.landApplicationStateList = landApplicationStateList;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }


    public String getSearchText1() {
        return searchText1;
    }

    public void setSearchText1(String searchText1) {
        this.searchText1 = searchText1;
    }

    public String getSearchText2() {
        return searchText2;
    }

    public void setSearchText2(String searchText2) {
        this.searchText2 = searchText2;
    }

    public String getSearchText3() {
        return searchText3;
    }

    public void setSearchText3(String searchText3) {
        this.searchText3 = searchText3;
    }

    public String getSearchText4() {
        return searchText4;
    }

    public void setSearchText4(String searchText4) {
        this.searchText4 = searchText4;
    }

    public void setMigrationStateList(Map<Integer, String> migrationStateList) {
        this.migrationStateList = migrationStateList;
    }

    public Map<Integer, String> getMigrationStateList() {
        return migrationStateList;
    }

    public boolean isShowNextButton() {
        return showNextButton;
    }

    public void setShowNextButton(boolean showNextButton) {
        this.showNextButton = showNextButton;
    }

    public Map<Integer, String> getIPWZoneList() {
        return IPWZoneList;
    }

    public void setIPWZoneList(Map<Integer, String> IPWZoneList) {
        this.IPWZoneList = IPWZoneList;
    }

    public Map<Integer, String> getRailwayProtectionZoneList() {
        return railwayProtectionZoneList;
    }

    public void setRailwayProtectionZoneList(Map<Integer, String> railwayProtectionZoneList) {
        this.railwayProtectionZoneList = railwayProtectionZoneList;
    }

    public Map<Integer, String> getRailwayStationList() {
        return railwayStationList;
    }

    public void setRailwayStationList(Map<Integer, String> railwayStationList) {
        this.railwayStationList = railwayStationList;
    }

    public Map<Integer, String> getDistrictEngineerZoneList() {
        return districtEngineerZoneList;
    }

    public void setDistrictEngineerZoneList(Map<Integer, String> districtEngineerZoneList) {
        this.districtEngineerZoneList = districtEngineerZoneList;
    }

    public Map<Integer, String> getRailwayTrackList() {
        return railwayTrackList;
    }

    public void setRailwayTrackList(Map<Integer, String> railwayTrackList) {
        this.railwayTrackList = railwayTrackList;
    }
}
